package com.io.input;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class BufferedInputFile {

	public static String read(String filename) throws IOException {
		// FileReader打开文件用于字符输入
		// BufferedReader为了提高读取速度，需要对文件进行缓存，我们将产生的引用传递给BufferedReader构造器
		BufferedReader in = new BufferedReader(new FileReader(filename));

		String s;
		StringBuilder sb = new StringBuilder();
		while ((s = in.readLine()) != null) {
			sb.append(s + "\n");
		}
		in.close();

		return sb.toString();
	}

	public static void main(String[] args) throws IOException {
		System.out
				.println(read("F:/workspace_luna/demo_thinkinjava/src/com/io/input/BufferedInputFile.java"));
	}

}
